//
//  Radio_Header_CollectionViewCell.m
//  Time
//
//  Created by dllo on 16/7/22.
//  Copyright © 2016年 司昌宝. All rights reserved.
//

#import "Radio_Header_CollectionViewCell.h"

@interface Radio_Header_CollectionViewCell ()
/**
 *  按钮
 */
@property (nonatomic,retain) UIButton *button;
/**
 *  cell名
 */
@property (nonatomic,retain) UILabel *nameLabel;
@end

@implementation Radio_Header_CollectionViewCell

-(void)dealloc{
    [_button release];
    [_buttonName release];
    [_nameLabel release];
    [_imageName release];
    [super dealloc];
}

-(instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.button = [UIButton buttonWithType:UIButtonTypeCustom];
        [self.contentView addSubview:self.button];
        
        self.nameLabel = [[UILabel alloc] init];
        [self.contentView addSubview:self.nameLabel];
        [_nameLabel release];
    }
    return self;
}

-(void)layoutSubviews{
    [super layoutSubviews];
    
    [self.button mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView.mas_left).offset(0);
        make.right.equalTo(self.contentView.mas_right).offset(0);
        make.top.equalTo(self.contentView.mas_top).offset(0);
        make.height.mas_equalTo(50);
    }];
    
    self.nameLabel.textAlignment = NSTextAlignmentCenter;
    [self.nameLabel mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.contentView.mas_left).offset(0);
        make.right.equalTo(self.contentView.mas_right).offset(0);
        make.top.equalTo(self.button.mas_bottom).offset(0);
        make.bottom.equalTo(self.contentView.mas_bottom).offset(0);
    }];
    
}

-(void)setButtonName:(NSString *)buttonName{
    if (_buttonName != buttonName){
        [_buttonName release];
        _buttonName = [buttonName retain];
    }
    self.nameLabel.text = buttonName;
}

-(void)setImageName:(NSString *)imageName{
    if (_imageName != imageName) {
        [_imageName release];
        _imageName = [imageName retain];
    }
    [self.button setImage:[UIImage imageNamed:imageName] forState:UIControlStateNormal];
}

@end
